package com.ww.nio.filechannel;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

/**
 * 利用transferFrom方法实现文件拷贝
 * @author wanggw
 * 2023年10月17日 下午9:34:25
 */
public class NIOFileChannel02 {

	public static void main(String[] args) throws IOException {
		FileInputStream fileInputStream = new FileInputStream("");
		FileOutputStream fileOutputStream = new FileOutputStream("");
		
		FileChannel sourceChl = fileInputStream.getChannel();
		FileChannel destChl = fileOutputStream.getChannel();
		
		/**
		 * transferFrom实现拷贝
		 */
		destChl.transferFrom(sourceChl, 0, sourceChl.size());
		
		sourceChl.close();
		destChl.close();
		fileInputStream.close();
		fileOutputStream.close();
	}	
}
